<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    1032. Satisfiability of Equality Equations
   </h1>
   <p>
    Given an array
    <font face="monospace">
     equations
    </font>
    &nbsp;of strings that represent relationships between variables, each string
    <code>
     equations[i]
    </code>
    &nbsp;has length
    <code>
     4
    </code>
    and takes one of two different forms:
    <code>
     "a==b"
    </code>
    or
    <code>
     "a!=b"
    </code>
    .&nbsp; Here,
    <code>
     a
    </code>
    and
    <code>
     b
    </code>
    are lowercase letters (not necessarily different) that represent one-letter variable names.
   </p>
   <p>
    Return
    <code>
     true
    </code>
    &nbsp;if and only if it is possible to assign integers to variable names&nbsp;so as to satisfy all the given equations.
   </p>
   <p>
    &nbsp;
   </p>
   <ol>
   </ol>
   <div>
    <p>
     <strong>
      Example 1:
     </strong>
    </p>
    <pre>
<strong>Input: </strong><span id="example-input-1-1">["a==b","b!=a"]</span>
<strong>Output: </strong><span id="example-output-1">false</span>
<strong>Explanation: </strong>If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second.  There is no way to assign the variables to satisfy both equations.
</pre>
    <div>
     <p>
      <strong>
       Example 2:
      </strong>
     </p>
     <pre>
<strong>Input: </strong><span id="example-input-2-1">["b==a","a==b"]</span>
<strong>Output: </strong><span id="example-output-2">true</span>
<strong>Explanation: </strong>We could assign a = 1 and b = 1 to satisfy both equations.
</pre>
     <div>
      <p>
       <strong>
        Example 3:
       </strong>
      </p>
      <pre>
<strong>Input: </strong><span id="example-input-3-1">["a==b","b==c","a==c"]</span>
<strong>Output: </strong><span id="example-output-3">true</span>
</pre>
      <div>
       <p>
        <strong>
         Example 4:
        </strong>
       </p>
       <pre>
<strong>Input: </strong><span id="example-input-4-1">["a==b","b!=c","c==a"]</span>
<strong>Output: </strong><span id="example-output-4">false</span>
</pre>
       <div>
        <p>
         <strong>
          Example 5:
         </strong>
        </p>
        <pre>
<strong>Input: </strong><span id="example-input-5-1">["c==c","b==d","x!=z"]</span>
<strong>Output: </strong><span id="example-output-5">true</span>
</pre>
        <p>
         &nbsp;
        </p>
        <p>
         <strong>
          Note:
         </strong>
        </p>
        <ol>
         <li>
          <code>
           1 &lt;= equations.length &lt;= 500
          </code>
         </li>
         <li>
          <code>
           equations[i].length == 4
          </code>
         </li>
         <li>
          <code>
           equations[i][0]
          </code>
          and
          <code>
           equations[i][3]
          </code>
          are lowercase letters
         </li>
         <li>
          <code>
           equations[i][1]
          </code>
          is either
          <code>
           '='
          </code>
          or
          <code>
           '!'
          </code>
         </li>
         <li>
          <code>
           equations[i][2]
          </code>
          is&nbsp;
          <code>
           '='
          </code>
         </li>
        </ol>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div>
   <h1 class="question_title">
    1032. 等式方程的可满足性
   </h1>
   <p>
    给定一个由表示变量之间关系的字符串方程组成的数组，每个字符串方程
    <code>
     equations[i]
    </code>
    的长度为
    <code>
     4
    </code>
    ，并采用两种不同的形式之一：
    <code>
     "a==b"
    </code>
    或&nbsp;
    <code>
     "a!=b"
    </code>
    。在这里，a 和 b 是小写字母（不一定不同），表示单字母变量名。
   </p>
   <p>
    只有当可以将整数分配给变量名，以便满足所有给定的方程时才返回&nbsp;
    <code>
     true
    </code>
    ，否则返回
    <code>
     false
    </code>
    。&nbsp;
   </p>
   <p>
    &nbsp;
   </p>
   <ol>
   </ol>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>["a==b","b!=a"]
<strong>输出：</strong>false
<strong>解释：</strong>如果我们指定，a = 1 且 b = 1，那么可以满足第一个方程，但无法满足第二个方程。没有办法分配变量同时满足这两个方程。
</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输出：</strong>["b==a","a==b"]
<strong>输入：</strong>true
<strong>解释：</strong>我们可以指定 a = 1 且 b = 1 以满足满足这两个方程。
</pre>
   <p>
    <strong>
     示例 3：
    </strong>
   </p>
   <pre><strong>输入：</strong>["a==b","b==c","a==c"]
<strong>输出：</strong>true
</pre>
   <p>
    <strong>
     示例 4：
    </strong>
   </p>
   <pre><strong>输入：</strong>["a==b","b!=c","c==a"]
<strong>输出：</strong>false
</pre>
   <p>
    <strong>
     示例 5：
    </strong>
   </p>
   <pre><strong>输入：</strong>["c==c","b==d","x!=z"]
<strong>输出：</strong>true
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= equations.length &lt;= 500
     </code>
    </li>
    <li>
     <code>
      equations[i].length == 4
     </code>
    </li>
    <li>
     <code>
      equations[i][0]
     </code>
     和&nbsp;
     <code>
      equations[i][3]
     </code>
     &nbsp;是小写字母
    </li>
    <li>
     <code>
      equations[i][1]
     </code>
     要么是&nbsp;
     <code>
      '='
     </code>
     ，要么是&nbsp;
     <code>
      '!'
     </code>
    </li>
    <li>
     <code>
      equations[i][2]
     </code>
     &nbsp;是&nbsp;
     <code>
      '='
     </code>
    </li>
   </ol>
  </div>
 </body>
</html>